/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.projet.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Oussama
 */
@Entity
@Table(name = "utilisateur")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Utilisateur.findAll", query = "SELECT u FROM Utilisateur u"),
    @NamedQuery(name = "Utilisateur.findByMotDePasse", query = "SELECT u FROM Utilisateur u WHERE u.motDePasse = :motDePasse"),
    @NamedQuery(name = "Utilisateur.findByEmail", query = "SELECT u FROM Utilisateur u WHERE u.email = :email"),
    @NamedQuery(name = "Utilisateur.findByName", query = "SELECT u FROM Utilisateur u WHERE u.name = :name"),
    @NamedQuery(name = "Utilisateur.findByNumCarteIdentite", query = "SELECT u FROM Utilisateur u WHERE u.numCarteIdentite = :numCarteIdentite"),
    @NamedQuery(name = "Utilisateur.findByNumTelephone", query = "SELECT u FROM Utilisateur u WHERE u.numTelephone = :numTelephone"),
    @NamedQuery(name = "Utilisateur.findByPrenom", query = "SELECT u FROM Utilisateur u WHERE u.prenom = :prenom"),
    @NamedQuery(name = "Utilisateur.findByRole", query = "SELECT u FROM Utilisateur u WHERE u.role = :role")})
public class Utilisateur implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "mot_de_passe")
    private String motDePasse;
    @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 255)
    @Column(name = "email")
    private String email;
    @Size(max = 255)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Column(name = "num_carte_identite")
    private int numCarteIdentite;
    @Basic(optional = false)
    @NotNull
    @Column(name = "num_telephone")
    private int numTelephone;
    @Size(max = 2147483647)
    @Column(name = "prenom")
    private String prenom;
    @Size(max = 2147483647)
    @Column(name = "role")
    private String role;

    public Utilisateur() {
    }

    public Utilisateur(String motDePasse) {
        this.motDePasse = motDePasse;
    }

    public Utilisateur(String motDePasse, int numCarteIdentite, int numTelephone) {
        this.motDePasse = motDePasse;
        this.numCarteIdentite = numCarteIdentite;
        this.numTelephone = numTelephone;
    }

    public String getMotDePasse() {
        return motDePasse;
    }

    public void setMotDePasse(String motDePasse) {
        this.motDePasse = motDePasse;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNumCarteIdentite() {
        return numCarteIdentite;
    }

    public void setNumCarteIdentite(int numCarteIdentite) {
        this.numCarteIdentite = numCarteIdentite;
    }

    public int getNumTelephone() {
        return numTelephone;
    }

    public void setNumTelephone(int numTelephone) {
        this.numTelephone = numTelephone;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (motDePasse != null ? motDePasse.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Utilisateur)) {
            return false;
        }
        Utilisateur other = (Utilisateur) object;
        if ((this.motDePasse == null && other.motDePasse != null) || (this.motDePasse != null && !this.motDePasse.equals(other.motDePasse))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.projet.entities.Utilisateur[ motDePasse=" + motDePasse + " ]";
    }
    
}
